import {createSlice} from "@reduxjs/toolkit";
import {getTrademarkList} from '@/api/first';
import { useSelector } from "react-redux";

const brandSlice = createSlice({
    name:"brand",
    initialState:{
       brandList:[],  
    },
    reducers:{
      upBrandList(state,{payload}){
        state.brandList = payload
      }
    },
}) 

const {upBrandList} = brandSlice.actions;
export const getTrademarkListAsync = (page:number,limit:number)=>{
    return async (dispatch:any)=>{
        const result = await getTrademarkList(page,limit);
        dispatch(upBrandList(result));
        console.log(result)
    }
}

export const useSelectorBrand = ()=> useSelector((state:any)=>state.brand);
export default brandSlice.reducer;

